<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f"%>
<%@ taglib uri="/WEB-INF/tld/mobai-el-common.tld" prefix="el"%>
<!DOCTYPE html PUBLIC>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>店主列表</title>
<link rel="Bookmark" href="/three/favicon.ico">
<link rel="Shortcut Icon" href="/three/favicon.ico" />
<link rel="stylesheet" type="text/css"
	href="/three/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css"
	href="/three/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css"
	href="/three/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css"
	href="/three/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css"
	href="/three/static/h-ui.admin/css/style.css" />
</head>
<body style="margin:5px">
	<!-- Modal -->
	<!-- ----------------------------------------添加/修改  模态框开始 -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel" aria-hidden="true"
		style="display: none">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<h3 class="modal-title">店主信息维护</h3>
					<a class="close" data-dismiss="modal" aria-hidden="true"
						href="javascript:void();">×</a>
				</div>
				<div class="modal-body">
					<!-- ---------------------------------------添加/修改模态框内容开始------------------------------------ -->
					<form action="/three/ly/save" method="post" id="formadd"
						enctype="multipart/form-data">
						<input type="hidden" name="shopUserId" id="shopUserId" value=""
							class="input-text radius" />
						<table class="table-sort">
							<tr>
								<td>店主账号：</td>
								<td><input class="input-text" type="text" name="account"
									id="account" style="width: 150px; height: 25px"></td>
								<td>姓名：</td>
								<td><input class="input-text" type="text" name="username"
									id="username" style="width: 150px; height: 25px"></td>
							</tr>


							<tr>
								<td>密码：</td>
								<td><input class="input-text" type="password"
									name="password" id="password"
									style="width: 150px; height: 25px"></td>
								<td>确认密码：</td>
								<td><input class="input-text" type="password"
									name="secendpassword" id="secendpassword"
									style="width: 150px; height: 25px"></td>
							</tr>


							<tr>
								<td>手机：</td>
								<td><input class="input-text" type="text" name="mobile"
									id="mobile" style="width: 150px; height: 25px"></td>
								<td>身份证：</td>
								<td><input class="input-text" type="text" name="idno"
									id="idno" style="width: 150px; height: 25px"></td>
							</tr>

							<tr>
								<td>电话：</td>
								<td><input class="input-text" type="text" name="phone"
									id="phone" style="width: 150px; height: 25px"></td>
								<td>邮箱：</td>
								<td><input class="input-text" type="text" name="email"
									id="email" style="width: 150px; height: 25px"></td>
							</tr>
							<tr>
								<td>性别：</td>
								<td><select name="sex" id="sex" class="select"
									style="width: 150px; height: 25px">
										<option value="1">男</option>
										<option value="2">女</option>
										<option value="0">保密</option>
								</select></td>
								<td>用户状态：</td>
								<td><select name="status" id="status" class="select"
									style="width: 150px; height: 25px">
										<option value="1">启用</option>
										<option value="0">禁用</option>
								</select></td>
							</tr>
							<tr>
								<td>备注</td>
								<td colspan="3">
									<!--<input type="hidden" name="shopId" 	id="shopId" />--> <textarea
										name="remark" id="remark" rows="3" cols="30" name=""
										class="textarea "></textarea>
								</td>
							</tr>
						</table>
					</form>
					<!-- ---------------------------------------模态框内容结束------------------------------------ -->

				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-primary" id="btn_save">确定</button>
					<button type="button" class="btn btn-default" data-dismiss="modal"
						aria-hidden="true">关闭</button>
				</div>
			</div>
		</div>
	</div>
	<!-- 添加 修改员工信息模态框结束--------------------------------------------------- -->

	<!-- --------------------------------------------------修改密码模态框开始 ---------------------------------------------------------->
	<div id="modal" class="modal fade" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content radius">
				<div class="modal-header">
					<h3 class="modal-title">重置密码</h3>
					<a class="close" data-dismiss="modal" aria-hidden="true"
						href="javascript:void();">×</a>
				</div>
				<div class="modal-body">
					<!------ ----------------------模态框内容部分开始---------------------------------------------------- -->
					<form class="form form-horizontal" id="form"
						action="/three/ly/shopuser_to_update_password" method="post">
						<table style="height: 100px">
							<tr>
								<td align="right"><span style="font-size: 15px">请输入新密码：</span></td>
								<td align="left"><input type="password" name="password"
									id="password2" value="" style="width: 250px"
									class="input-text radius" /></td>
							</tr>
							<tr>
								<td align="right"><span style="font-size: 15px">确认密码：</span></td>
								<td align="left"><input type="password"
									name="secendpassword" id="secendpassword2" value=""
									style="width: 250px" class="input-text radius" /></td>
							</tr>
						</table>
					</form>
					<!------ ----------------------模态框内容部分结束---------------------------------------------------- -->
				</div>
				<div class="modal-footer">
					<button class="btn btn-secondary radius" type="button" id="but2">
						<i class="Hui-iconfont">&#xe632;</i> 保存
					</button>
					<button class="btn radius" data-dismiss="modal" aria-hidden="true">关闭</button>
				</div>
			</div>
		</div>
	</div>
	<!-- 修改密码模态框结束--------------------------------------------------- -->


	<!----------------------------------------- 综合查询开始 ---------------------------------------->
	<form action="/three/ly/shoplist" method="post">
		店主账号：<input class="input-text" type="text" name="account"
			style="width: 150px; height: 25px"> 姓名：<input
			class="input-text" type="text" name="username"
			style="width: 150px; height: 25px"> 状态：<select name="status"
			class="select" style="width: 150px; height: 25px">
			<option value=""></option>
			<option value="1">在职</option>
			<option value="0">离职</option>
		</select><br> 手机：<input class="input-text" type="text" name="mobile"
			style="width: 150px; height: 25px"> 身份证：<input
			class="input-text" type="text" name="card"
			style="width: 150px; height: 25px"> 邮箱：<input
			class="input-text" type="text" name="email"
			style="width: 150px; height: 25px">
		<button type="submit" class="btn btn-primary">
			<i class="Hui-iconfont">&#xe665;</i>查询
		</button>
		<button class="btn btn-primary" type="submit" id="btn_reset">
			<i class="Hui-iconfont">&#xe68f;</i>重置
		</button>
		<!----------------------------------------- 综合查询结束 ---------------------------------------->






		<!----------------------------------------- 添加开始 ---------------------------------------->
		<div class="cl pd-5 bg-1 bk-gray mt-20">
			<span class="1"> <a href="javascript:;" onclick="admin_add()"
				class="btn btn-primary radius"> <i class="Hui-iconfont">&#xe600;</i>
					添加
			</a>
			</span><span class="1"></span>

		</div>
		<!----------------------------------------- 添加结束 ---------------------------------------->

		<!-------------------------------------------- 查询所有开始----------------------------------------------->
		<table id="table"
			class="table table-border table-bordered table-hover table-bg table-sort">
			<thead>
				<tr>
					<th>店主账号</th>
					<th>姓名</th>
					<th>性别</th>
					<th>手机</th>
					<th>身份证</th>
					<th>邮箱</th>
					<th>电话</th>
					<th>状态</th>
					<th>创建时间</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${shoplist }" var="shopkeeper">
					<tr>
						<td>${shopkeeper.account }</td>
						<td>${shopkeeper.username }</td>
						<td><c:if test="${shopkeeper.sex==1 }">男</c:if> <c:if
								test="${shopkeeper.sex==2 }">女</c:if> <c:if
								test="${shopkeeper.sex==0 }">保密</c:if></td>
						<td>${shopkeeper.mobile }</td>
						<td>${shopkeeper.idno }</td>
						<td>${shopkeeper.email }</td>
						<td>${shopkeeper.phone }</td>
						<td>${shopkeeper.status==0?'离职':'在职' }</td>
						<td><f:formatDate value="${shopkeeper.createTime }"
								pattern="yyyy-MM-dd HH:mm:ss" /></td>
						<td><a style="text-decoration: none" href="javascript:;"
							onclick='admin_update(${el:toJsonString(shopkeeper)})' title="编辑">
								<i class="Hui-iconfont">&#xe6df;</i>
						</a> <a style="text-decoration: none" class="ml-5"
							href="/three/ly/deleteshopkeeper?shopUserId=${shopkeeper.shopUserId }"
							title="删除"> <i class="Hui-iconfont">&#xe6e2;</i>
						</a> <a style="text-decoration: none" href="javascript:;" class="ml-5"
							onclick="shopuser_update_password('${shopkeeper.shopUserId}') "
							title="修改密码"> <i class="Hui-iconfont">&#xe63f;</i>
						</a></td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</form>
	<!-------------------------------------------- 查询所有结束----------------------------------------------->


	<!--_footer 作为公共模版分离出去-->
	<script type="text/javascript" src="/three/lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="/three/lib/layer/2.4/layer.js"></script>
	<script type="text/javascript" src="/three/static/formEdit.js"></script>
	<script type="text/javascript" src="/three/static/h-ui/js/H-ui.min.js"></script>
	<script type="text/javascript"
		src="/three/static/h-ui.admin/js/H-ui.admin.js"></script>
	<script type="text/javascript"
		src="/three/lib/My97DatePicker/4.8/WdatePicker.js"></script>
	<script type="text/javascript"
		src="/three/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
	<script type="text/javascript" src="/three/lib/laypage/1.2/laypage.js"></script>
	<script type="text/javascript"
		src="/three/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
	<script type="text/javascript"
		src="/three/lib/jquery.validation/1.14.0/validate-methods.js"></script>
	<script type="text/javascript"
		src="/three/lib/jquery.validation/1.14.0/messages_zh.js"></script>
</body>
<script type="text/javascript">
		/*分页*/
		$('#table').dataTable({
			"aaSorting" : [ [ 1, "desc" ] ],//默认第几个排序
			"bStateSave" : true,//状态保存
			"pading" : false,
			"aoColumnDefs" : [ {
				"orderable" : false,
			//"aTargets" : [ 0, 8 ]
			} // 不参与排序的列
			]
		});
		/*表单验证*/
		$("#formadd").validate({
			rules : {
				account : { //店主账号
					required : true,//必须输入的字段
					minlength : 6,//输入长度最多是 6的字符串（汉字算一个字符）。
					maxlength : 12//输入长度最多是 12的字符串（汉字算一个字符）。
				},
				username : { //姓名
					required : true
					
				},
				password : { //密码
					required : true,
					minlength : 6,  //输入长度最多是 6的字符串（汉字算一个字符）。
					maxlength : 22  //输入长度最多是 12的字符串（汉字算一个字符）。
					
				},
				secendpassword : { //确定密码					
					required : true,
				},
				mobile : { //手机号
					required : true,
					number : true
				},
				email : { //邮箱
					required : true,
					digits : true//必须输入整数。
				},
				idno : { //身份证号
					required : true
				},
				phone : { //电话
					required : true
				},	
				

				onkeyup : false,
				focusCleanup : true
			}
		});
		/*管理员-增加*/
		function admin_add() {
			$('#myModal').modal('show');
		} 
 	

		/*管理员-查看详情*/
		function admin_select() {
			$('#myModal').modal('show');
		}
		/*点击重置按钮开始*/
		$("#btn_reset").click(function() {
			$(".input-text").val("");
			$(".textarea").val("");
			$("#number").val("1");
		});
		/*点击重置按钮结束*/
		
		
		
		/* $.ajax({//异步请求获取店主账号
			type : "POST",
			url : "/three/ly/queryShopUserAccount",
			success : function(msg) {
				$.each(msg, function(inde, obj) {
					$("#ownerId").append(
							"<option value='"+obj.shopUserId+"'>" + obj.account
									+ "</option>")

				})
			}
		}); */
		/**
		添加店铺信息
		 */
		/*$("#btn_save").click(function() {//保存事件
			var shopUserIdValue = $("#shopUserId").val();
			if (shopUserIdValue == "") {
				$("#addform").attr("action", "/three/ly/saveshopkeeper")
				$("#addform").submit();
			} else {
				$("#addform").attr("action", "/three/ly/updateshopkeeper")
				$("#addform").submit();
			}
		});
		 */
		/**
		修改店主信息--给数据赋值
		*/
		function admin_update(shopkeeper){
			$.ajax({
				type : "POST",
				url : "/three/ly/toupdateshopkeeper",
				dataType : "json",
				async : false,//异步的;
				data : {
					shopUserId : shopkeeper.shopUserId
				},
				//成功后开启模态框
				success : function(data) {
					$("#formadd").formEdit(shopkeeper);//自动填值,括号里的值通过					
					$("#secendpassword").val(shopkeeper.password);
					//显示模态框					
					$("#myModal").modal("show");
					
				}
			});
		}
		
		
		/*店主信息-刷新模态框*/
		$('#myModal').on('hidden.bs.modal', function () {
			window.location.reload();
		});
		
		
		/*店主信息-添加++修改*/
		$("#btn_save").on("click",function(){
			if($("#password").val()==$("#secendpassword").val()){
				if($("#shopUserId").val()==""){
					$("#formadd").attr("action", "/three/ly/saveshopkeeper")
					$("#formadd").submit();				
				}else{
					$("#formadd").attr("action", "/three/ly/updateshopkeeper")
					$("#formadd").submit();	
					
				}
			}else{
				alert("两次输入密码不一致！！！");
			}
		});
		
		/*店主信息-修改密码打开模态框*/
		function shopuser_update_password(shopUserId){
			$("#modal").modal("show");
			/*员工信息-修改密码*/
			$("#but2").on("click",function(){
				if($("#password2").val()==$("#secendpassword2").val()){
					layer.confirm('确认要修改吗？',function(index){
					//console.log($("#toPassword2").val());
					$("#form").attr("action","/three/ly/user_update_password?shopUserId="+shopUserId+"&password2="+$("#secendpassword2").val());
					$("#form").submit();
					layer.msg('已修改!',{icon:1,time:1000});
					});
				}else{
					alert("两次密码输入不一致！！！");
				}
			});
		}	
		
		
	</script>

</body>
</html>